package main;

import bots.RandomBot;
import bots.lookahead.SimpleLookAheadBot;
import gui.GuiClient;
import gui.HumanPlayer;
import model.*;
import org.apache.log4j.Logger;

import java.util.concurrent.ForkJoinPool;

/**
 * @author Alex Vikharev vikharev@yandex-team.ru
 *         created 25.01.12
 */
public class HumanVsBotGame {
    private final static Logger log = Logger.getLogger(HumanVsBotGame.class);


    public static void main(String[] args) throws Exception {
        ForkJoinPool pool = new ForkJoinPool();
        Player bot1 = new SimpleLookAheadBot(GameType.IMPROVED, "smart", 1, pool);
        Player bot2 = new RandomBot("smart", GameType.IMPROVED);

//        Player bot2 = new WekaBot("wekabot", GameType.IMPROVED, WekaClassifier.teach("small.arff"));

        int firstWin = 0;
        int secondWin = 0;
        for (int i = 0; i < 100; i++) {
            if (i % 1 == 0) {
                log.fatal("" + i + " firstWin = " + firstWin + " , secondWin = " + secondWin);
            }
            Game game = new Game(bot1, bot2, GameType.IMPROVED);
            game.go();
            if (game.getState() == GameState.FIRST_PLAYER_WIN) {
                firstWin++;
            } else if (game.getState() == GameState.SECOND_PLAYER_WIN) {
                secondWin++;
            }
        }
        System.err.println("firstWin = " + firstWin + " , secondWin = " + secondWin);


        GuiClient client = new GuiClient();
         bot1= new HumanPlayer(client);
        Game game = new Game(bot1, bot2, GameType.IMPROVED);
        game.setWatcher(client);
        game.go();
        System.out.println(game.getState());
        pool.shutdown();
    }
}
